CREAT

Section: MINTLIB LIBRARY FUNCTIONS (3)
Updated: 3 March 1993
Index Return to Main Contents
 

NAME

creat - create a new file  

SYNOPSIS

#include <unistd.h>

int creat(const char *path, unsigned int mode);
 

DESCRIPTION

This interface is made obsolete by open, since,
  creat(path, mode); is equivalent to
  open(path, O_WRONLY | O_CREAT | O_TRUNC, mode); which actually is the way creat is implemented. creat creates a new ordinary file or prepares to rewrite an existing file named by the pathname pointed to by path. If the file did not exist, it is given the mode 'mode', as modified by the process's mode mask (see umask). See stat for the construction of mode. If the file exists, its mode and owner remain unchanged, but it is truncated to 0 length. Otherwise, the file's owner ID is set to the effective user ID of the process, and upon successful completion, creat marks for update the st_atime, st_ctime, and st_mtime fields of the file (see stat) and the st_ctime and st_mtime fields of the parent directory. Upon successful completion, the file descriptor is returned and the file is open for writing, even if the access permis- sions of the file mode do not permit writing. The file pointer is set to the beginning of the file. The file descriptor is set to remain open across execve system calls. See fcntl.  

RETURN VALUES

creat returns a non-negative descriptor that only permits writing on success. On failure, it returns -1 and sets errno to indicate the error.  

SEE ALSO

close(3), chmod(3), execve(3), fcntl(3), flock(3), open(3), write(3), umask(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUES
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 11:15:08 GMT, June 22, 2025